/*
 * @Description: 公共AppBar
 * @version: 
 * @Company: 
 * @Author: ZhengZhuang
 * @Date: 2019-08-23 12:01:52
 * @LastEditors: ZhengZhuang
 * @LastEditTime: 2019-08-24 09:14:59
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class AppbarWidget extends StatefulWidget implements PreferredSizeWidget {
  String title;
  Color color;
  AppbarWidget(this.title, {this.color});
  @override
  State<AppbarWidget> createState() => _AppbarWidgetState();

  @override
  Size get preferredSize {
    return new Size.fromHeight(56.0);
  }
}

class _AppbarWidgetState extends State<AppbarWidget> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return new Container(
      color:
          widget.color == null ? Color.fromARGB(255, 78, 79, 95) : widget.color,
      width: ScreenUtil().setWidth(750),
      child: Container(
        margin: EdgeInsets.only(top: 20.0),
        alignment: Alignment.centerLeft,
        child: Row(
          children: <Widget>[
            Container(
              // color: Colors.yellow,
              width: ScreenUtil().setWidth(100),
              child: IconButton(
                icon: Icon(Icons.arrow_back),
                color: widget.color != null ? Colors.black : Colors.white,
                onPressed: () {
                  Navigator.pop(context);
                },
              ),
            ),
            SizedBox(
              width: ScreenUtil().setWidth(30.0),
            ),
            Expanded(
              child: Text(
                widget.title,
                style: TextStyle(
                  color: widget.color != null ? Colors.black : Colors.white,
                  fontSize: 20.0,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
